﻿// (c)2010 David Schwarz (david.schwarz@live.com)
// This file is licensed under GNU GPL v2 license, see more at http://www.gnu.org/licenses/gpl-2.0.html
namespace Z2.Core
{

	#region Using

	using Microsoft.Xna.Framework;
	using Microsoft.Xna.Framework.Graphics;

	#endregion

	/// <summary>
	/// Třída definující políčko mapy
	/// </summary>
	public class WorldField
	{

		#region Const

		public const int SIZE = 32; // Velikost políčka

		#endregion

		#region Members

		private bool m_isSolid;
		private Sprite m_sprite;
		private Vector2 m_position;

		#endregion

		#region Constructor

		/// <summary>
		/// Konstruktor
		/// </summary>
		/// <param name="definition">Definice</param>
		public WorldField(FieldDefinition definition)
		{
			this.m_isSolid = definition.Solid;
			this.m_sprite = SpriteManager.Instance.LoadSpriteCache(
				definition.Graphics, 
				definition.FramesX, 
				definition.FramesY, 
				World.WORLD_DIR);
		}

		#endregion

		#region Methods
		
		/// <summary>
		/// Metoda vykreslí toto políčko
		/// </summary>
		/// <param name="batch"></param>
		/// <param name="position"></param>
		public void Draw(SpriteBatch batch, Vector2 position)
		{
			this.m_sprite.Draw(batch, position);
		}
		
		#endregion

		#region Properties

		/// <summary>
		/// Nastavuje nebo vrací pozici
		/// </summary>
		public Vector2 Position
		{
			get
			{
				return this.m_position;
			}
			set
			{
				this.m_position = value;
			}
		}
		
		/// <summary>
		/// Vrací zda je toto políčko průchozí
		/// </summary>
		public bool IsSolid
		{
			get
			{
				return this.m_isSolid;
			}
		}

		#endregion

	}
}
